<!DOCTYPE html>
<html lang="Chinese, English">
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="Green" />



<meta name="description" content="第一次接触背景渐变的时候其实没什么感觉，但自从看了《CSS揭秘》后发现背景渐变可以有很多种玩法，可以替代一部分图片实现的内容，效果非常棒">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS背景渐变">
<meta property="og:url" content="https://greenmzc.github.io/2016/12/14/CSS背景渐变/index.html">
<meta property="og:site_name" content="Green的博客 | Green's Blog">
<meta property="og:description" content="第一次接触背景渐变的时候其实没什么感觉，但自从看了《CSS揭秘》后发现背景渐变可以有很多种玩法，可以替代一部分图片实现的内容，效果非常棒">
<meta property="og:image" content="https://greenmzc.github.io/img/2016120701.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016120702.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016120801.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016120901.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121301.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121302.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121303.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121304.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121305.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121401.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121402.png">
<meta property="og:image" content="https://greenmzc.github.io/img/2016121403.png">
<meta property="og:updated_time" content="2016-12-14T09:11:47.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CSS背景渐变">
<meta name="twitter:description" content="第一次接触背景渐变的时候其实没什么感觉，但自从看了《CSS揭秘》后发现背景渐变可以有很多种玩法，可以替代一部分图片实现的内容，效果非常棒">
<meta name="twitter:image" content="https://greenmzc.github.io/img/2016120701.png">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="Green的博客 | Green&#39;s Blog" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/green/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>CSS背景渐变 | Green的博客 | Green&#39;s Blog</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: undefined
    }
</script>


    <script> yiliaConfig.jquery_ui = [false]; </script>



    <script> yiliaConfig.rootUrl = "\/";</script>



    <script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-56ff76c972fc0cf9"></script>



    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?74f5c9dc68aa8b1babf7bd3c11285f9b";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">Green</a></h1>
        </hgroup>

        

        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:15869186780@163.com" title="Email"></a>
                            
                                <a class="fa GitHub" href="https://github.com/Greenmzc" title="GitHub"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/D3/">D3</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/css/">css</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/shell/">shell</a></li></ul>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="http://fangyi.me">Phieo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://excaliburhan.com">虚夜宫</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://www.ggfly.me">郁川溪畔</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://nickliuyong.github.io/blogs/">NickLiu</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://blog.icdoit.com">没事溜达</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://www.lixuejiang.me">风君子</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">专注于前端</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">Green</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">Green</a></h1>
            </hgroup>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:15869186780@163.com" title="Email"></a>
                            
                                <a class="fa GitHub" target="_blank" href="https://github.com/Greenmzc" title="GitHub"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我"/>
</nav>
      <div class="body-wrap"><article id="post-CSS背景渐变" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2016/12/14/CSS背景渐变/" class="article-date">
      <time datetime="2016-12-14T08:58:49.000Z" itemprop="datePublished">2016-12-14</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      CSS背景渐变
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        

        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/css/">css</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <p>第一次接触背景渐变的时候其实没什么感觉，但自从看了《CSS揭秘》后发现背景渐变可以有很多种玩法，可以替代一部分图片实现的内容，效果非常棒</p>
<a id="more"></a>
<h3 id="线性渐变"><a href="#线性渐变" class="headerlink" title="线性渐变"></a>线性渐变</h3><p>css背景渐变基本语法格式：</p>
<p>background: <code>linear-gradient</code>( [ <code>&lt;angle&gt;</code> | to <code>&lt;side-or-corner&gt;</code> , ] ? <code>&lt;color-stop&gt;</code> [ , <code>&lt;color-stop&gt;</code>]+ )</p>
<p>第一个参数是代表渐变的角度方向，可以是角度值或者方向顺序</p>
<p>默认角度为180deg，代表渐变方向是垂直向下的，90度是水平向右，对应的方向顺序也可写成<code>to bottom</code>、<code>to right</code></p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(#0f0, #00f); <span class="comment">/* to bottom */</span></div><div class="line">  <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(90deg, #0f0, #00f); <span class="comment">/* to right */</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<img src="/img/2016120701.png" width="150" height="150" title="2016120701">
<img src="/img/2016120702.png" width="150" height="150" title="2016120702">
<p>第二个及之后的参数是颜色值与其起止位置</p>
<p>还是上面的例子，只指定颜色值，至少要指定两种颜色，默认将平均分配，每个色值各占比例相同。可以使用数值或者百分比调整渐变的长度，推荐使用百分比更加灵活。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(90deg, #0f0 50%, #00f 80%, #f00 100%);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<img src="/img/2016120801.png" width="150" height="150" title="2016120801">
<p>在一个位置的分界点设置不同的色值，可以做出条纹的效果</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(</div><div class="line">    #0f0 25%, #00f 25%,</div><div class="line">    #00f 50%, #f00 50%,</div><div class="line">    #f00 75%, #ff0 75%);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<img src="/img/2016120901.png" width="150" height="150" title="2016120901">
<h3 id="径向渐变"><a href="#径向渐变" class="headerlink" title="径向渐变"></a>径向渐变</h3><p>径向渐变基本语法格式类似：</p>
<p>background: <code>radial-gradient</code>( [ <code>&lt;bg-position&gt;</code> || <code>&lt;angle&gt;</code>, ] ? [ <code>&lt;shape&gt;</code> || <code>&lt;size&gt;</code>, ] ? <code>&lt;color-stop&gt;</code>, <code>&lt;color-stop&gt;</code> [ , <code>&lt;color-stop&gt;</code>]* )</p>
<p>第一个参数是代表渐变的位置，可以是方向的含义，也可以是确切的数值，默认在中心位置</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(#0f0, #f00);</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">-webkit-radial-gradient</span>(#0f0, #f00);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<img src="/img/2016121301.png" width="150" height="150" title="2016121301">
<p>设置渐变中心位置，使渐变中心在框的左上方</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(</div><div class="line">    top left,</div><div class="line">    #0f0, #f00); <span class="comment">/* 等价于 background: radial-gradient(0 0, #0f0, #f00); */</span></div><div class="line">  <span class="attribute">background</span>: <span class="built_in">-webkit-radial-gradient</span>(</div><div class="line">    top left,</div><div class="line">    #0f0, #f00);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<img src="/img/2016121302.png" width="150" height="150" title="2016121302">
<p>第二个参数是渐变的形状和大小，形状可以是<code>圆形</code>或者<code>椭圆</code>，大小有以下几个值</p>
<ul>
<li><code>closest-side</code> 近边</li>
<li><code>closest-corner</code> 近角</li>
<li><code>farthest-side</code> 远边</li>
<li><code>farthest-corner</code> 远角</li>
<li><code>contain</code> 背景图像完全覆盖背景区域</li>
<li><code>cover</code> 背景图像完全适应内容区域</li>
</ul>
<p>一般来说的大小排序为，近边&lt;近角&lt;远边&lt;远角，这是由于圆心到边的垂直距离要比点到角的距离更近，contain、cover和background-size中的contain、cover属性类似</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(</div><div class="line">    50px 50px,</div><div class="line">    ellipse closest-side,</div><div class="line">    #0f0, #f00); <span class="comment">/* 近边 */</span></div><div class="line">  <span class="attribute">background</span>: <span class="built_in">-webkit-radial-gradient</span>(</div><div class="line">    50px 50px,</div><div class="line">    ellipse closest-side,</div><div class="line">    #0f0, #f00);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<img src="/img/2016121303.png" width="150" height="150" title="2016121303">
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(</div><div class="line">    50px 50px,</div><div class="line">    ellipse farthest-corner,</div><div class="line">    #0f0, #f00); <span class="comment">/* 远角 */</span></div><div class="line">  <span class="attribute">background</span>: <span class="built_in">-webkit-radial-gradient</span>(</div><div class="line">    50px 50px,</div><div class="line">    ellipse farthest-corner,</div><div class="line">    #0f0, #f00);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<img src="/img/2016121304.png" width="150" height="150" title="2016121304">
<p>第三个及之后的参数是颜色值与其起止位置，与线性渐变一致</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.box</span> &#123;</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(</div><div class="line">    #0f0 15%, #f00 15%,</div><div class="line">    #f00 30%, #ff0 30%,</div><div class="line">    #ff0 45%, #0ff 45%,</div><div class="line">    #0ff 60%, #00f 60%);</div><div class="line">  <span class="attribute">background</span>: <span class="built_in">-webkit-radial-gradient</span>(</div><div class="line">    #0f0 15%, #f00 15%,</div><div class="line">    #f00 30%, #ff0 30%,</div><div class="line">    #ff0 45%, #0ff 45%,</div><div class="line">    #0ff 60%, #00f 60%);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>一个简单的靶图</p>
<img src="/img/2016121305.png" width="150" height="150" title="2016121305">
<h3 id="一些例子"><a href="#一些例子" class="headerlink" title="一些例子"></a>一些例子</h3><p>结合background-size，背景渐变可以玩出很多花样，下面是一个桌布条纹背景图</p>
<img src="/img/2016121401.png" width="500" height="250" title="2016121401">
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">body</span> &#123;</div><div class="line">  <span class="attribute">background</span>:</div><div class="line">    <span class="built_in">linear-gradient</span>(90deg, rgba(0, 0, 255, .6) <span class="number">50%</span>, transparent <span class="number">50%</span>),</div><div class="line">    <span class="built_in">linear-gradient</span>(rgba(0, 0, 255, .6) <span class="number">50%</span>, transparent <span class="number">50%</span>), white;</div><div class="line">  <span class="attribute">background-size</span>: <span class="number">50px</span> <span class="number">50px</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>结合background-position，可以移动渐变的位置，下面是一个铜板的平铺背景</p>
<img src="/img/2016121402.png" width="600" height="300" title="2016121402">
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">body</span> &#123;</div><div class="line">  <span class="attribute">background</span>:</div><div class="line">    <span class="built_in">linear-gradient</span>(45deg, #fff 15%, transparent 15%) <span class="number">35px</span> <span class="number">65px</span>,</div><div class="line">    <span class="built_in">linear-gradient</span>(45deg, transparent 85%, #fff 85%) -<span class="number">35px</span> <span class="number">35px</span>,</div><div class="line">    <span class="built_in">radial-gradient</span>(transparent 50%, rgba(255,255,255,0.4) <span class="number">50%</span>, <span class="built_in">rgba</span>(255,255,255,0.4) <span class="number">65%</span>, <span class="number">#fff</span> <span class="number">65%</span>),</div><div class="line">    <span class="number">#ffb521</span>;</div><div class="line">  <span class="attribute">background-size</span>: <span class="number">100px</span> <span class="number">100px</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>下面是一个星空背景图</p>
<img src="/img/2016121403.png" width="800" height="250" title="2016121402">
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">body</span> &#123;</div><div class="line">  <span class="attribute">background</span>:</div><div class="line">    <span class="built_in">radial-gradient</span>(white, rgba(255, 255, 255, .3) <span class="number">2px</span>, transparent <span class="number">40px</span>),</div><div class="line">    <span class="built_in">radial-gradient</span>(white, rgba(255, 255, 255, .2) <span class="number">1px</span>, transparent <span class="number">30px</span>),</div><div class="line">    <span class="built_in">radial-gradient</span>(white, rgba(255, 255, 255, .3) <span class="number">2px</span>, transparent <span class="number">50px</span>),</div><div class="line">    <span class="built_in">radial-gradient</span>(rgba(255, 255, 255, .4), <span class="built_in">rgba</span>(255, 255, 255, .1) <span class="number">2px</span>, transparent <span class="number">30px</span>),</div><div class="line">    black;</div><div class="line">  <span class="attribute">background-size</span>: <span class="number">400px</span> <span class="number">400px</span>, <span class="number">230px</span> <span class="number">230px</span>, <span class="number">310px</span> <span class="number">310px</span>, <span class="number">150px</span> <span class="number">150px</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>

      
    </div>
    
  </div>
  
    


    <nav id="article-nav">
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/2016/11/07/D3-js上手——饼状图/">
                    D3.js上手——饼状图
                </a>
            </div>
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#线性渐变"><span class="toc-number">1.</span> <span class="toc-text">线性渐变</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#径向渐变"><span class="toc-number">2.</span> <span class="toc-text">径向渐变</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#一些例子"><span class="toc-number">3.</span> <span class="toc-text">一些例子</span></a></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    

    
        <div class="addthis_sharing_toolbox"></div>
    
</div>




    
      <div class="duoshuo" id="comments">
    <div id="comment-box" ></div>
    <div class="ds-thread" id="ds-thread" data-thread-key="2016/12/14/CSS背景渐变/" data-title="CSS背景渐变" data-url="https://greenmzc.github.io/2016/12/14/CSS背景渐变/"></div>
    <script>
        var duoshuoQuery = {short_name:"greenmzc"};
        var loadComment = function(){
            var d = document, s = d.createElement('script');
            s.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
            s.async = true; s.charset = 'UTF-8';
            (d.head || d.body).appendChild(s);
        }

        
    </script>
    
    <script> loadComment(); </script>

</div>
    




    <div class="scroll" id="post-nav-button">
        
            <a href="/" title="回到主页"><i class="fa fa-home"></i></a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/2016/11/07/D3-js上手——饼状图/" title="下一篇: D3.js上手——饼状图">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2016/12/14/CSS背景渐变/">CSS背景渐变</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/11/07/D3-js上手——饼状图/">D3.js上手——饼状图</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/10/18/D3-js上手——折线图/">D3.js上手——折线图</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/10/11/D3-js入门/">D3.js入门</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/10/06/开始使用hexo搭建博客/">开始使用hexo搭建博客</a></li></ul>




    <script>
        
    </script>

</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i>
                2016-2017 Green
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="本站到访数"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="本页阅读量"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>

    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>





<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
            
            
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>